import numpy as np

# gt = np.array([1, 2, 2, 2, 2, 2, 2, 3, 4])
# mask = np.array([1, 2, 2, 3, 4, 2, 1, 1, 2])
#
# # 筛选gt中值为2的所有点位
# gt_value_2_indices = np.where(gt == 2)
# gt_value_2_mask_values = mask[gt_value_2_indices]
#
# # 统计mask中各个数值的比例
# unique_values, counts = np.unique(gt_value_2_mask_values, return_counts=True)
# proportions = counts / np.sum(counts)
#
# # 显示gt中所有值为2的点位
# print("Indices with value 2 in gt:")
# print(gt_value_2_indices)
#
# # 统计mask中各个数值的比例
# print("\nProportions of mask values for gt value 2:")
# for value, proportion in zip(unique_values, proportions):
#     print(f"Value {value}: Proportion {proportion:.2f}")

res = np.array([]).reshape(0, 4)
a=np.array([1,2,3,7])
b=np.array([4,5,6,5])
res = np.vstack([res, a])
res=np.vstack([res,b])
print(type(b),b.shape)
print(res)

#
# import numpy as np
#
# # 初始化一个空的数组作为容器
# res = np.array([]).reshape(0, 4)
#
# # 假设你有一系列 1*4 的数组，存储在变量 data_list 中
# data_list = [[1, 2, 3, 4],
#              [5, 6, 7, 8],
#              [9, 10, 11, 12]]
#
# # 循环将每个数组垂直堆叠到 res 中
# for arr in data_list:
#     res = np.vstack([res, arr])
#
# a=np.array([5,3,4,5])
# res=np.vstack([res,a])
# 打印结果
print("n*4 维数组:")
print(res)
